package exception;

import java.util.Scanner;

/**
 * @author tongchen
 * @create 2022-09-27 10:19
 */
public class MyException extends Throwable {
    private String exception;

    public MyException(String exception) {
        this.exception = exception;
    }

    public String getException() {
        return exception;
    }
}
class LogIn{
    private String usrName="小流氓";
    private String passWord="123456789";
    public void logIn() throws MyException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名");
        while(true){

            String name=scanner.nextLine();
            if (!name.equals(usrName)){
                System.out.println("不存在该用户名，请重新输入！");
            }
            else {
                break;
            }
        }
        System.out.println("请输入密码");
        String passward=scanner.nextLine();
        if (passward.equals(this.passWord)){
            System.out.println("登录成功......");
        }
        else {
            throw  new MyException("密码输入错误,登陆失败......");
        }
    }
}
